// 数据埋点操作
import axios from 'axios';
import sha1 from './sha1';

/**
 * 对老系统的公众号菜单跳转进行埋点
 * @param {String} appId app_id
 * @param {String} comId component_id
 */
export const buryRedirect = (appId, comId) => {
    const now = Date.now();
    const appKey = sha1(`A6980367948915UZAA000B23-E71F-CEA6-1115-D10AD558B51DUZ${now}`) + `.${now}`;
    return new Promise((resolve, reject) => {
        axios({
            method: 'POST',
            url: 'https://d.apicloud.com/mcm/api/bury',
            data: {
                app_id: appId,
                com_id: comId,
            },
            headers: {
                'X-APICloud-AppId': 'A6980367948915',
                'X-APICloud-AppKey': appKey,
            },
        });
    });
};
